package com.jiashihui.server1.utils;

public class StringUtil {

    /**
     * 去除前缀0
     * @return
     */
    public static String removePrefix(String str){
        return str.replaceAll("^(0+)", "");
    }

    /**
     * 截取第index个ch之后的字符串
     * @param ch
     * @param index
     * @return
     */
    public static String subStringBySeparator(String str, char ch, int index){
        if (index > 0) {
            return subStringBySeparator(str.substring(str.indexOf(ch) + 1), ch, --index);
        } else {
            return str;
        }
    }

    public static boolean isBlank(String str) {
        int length;
        if (str != null && (length = str.length()) != 0) {
            for(int i = 0; i < length; ++i) {
                if (!Character.isWhitespace(str.charAt(i))) {
                    return false;
                }
            }
            return true;
        } else {
            return true;
        }
    }

    public static void main(String[] args) {
        String str = "aaa_bbbb_ddkk_kkdd__ccc_dddd_111_666_uuuu.zip";
        System.out.println(subStringBySeparator(str,'_', 2));
    }
}
